package com.dzjcloud.dzj.common.satoken;

import cn.dev33.satoken.exception.NotPermissionException;
import com.dzjcloud.dzj.common.core.enums.ResultEnum;
import com.dzjcloud.dzj.common.core.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * <h3>dzj-cloud</h3>
 * <p>satoken异常处理类</p>
 *
 * @author : DongZeJian
 * @date : 2023-04-10 11:46
 **/
@RestControllerAdvice
@Slf4j
public class SatokenExceptionHandler {

    /**
     * 权限校验
     *
     * @param e
     * @return ResponseResult
     */
    @ExceptionHandler(NotPermissionException.class)
    public R notPermissionException(NotPermissionException e) {
        log.error("权限不通过:", e);
        return new R(ResultEnum.INSUFFICIENT_PERMISSIONS);
    }
}
